package com.example.lzbase;

import android.app.Application;

import com.google.gson.Gson;
import com.kaopiz.kprogresshud.KProgressHUD;

import org.greenrobot.eventbus.EventBus;

import java.util.Map;

import androidx.annotation.NonNull;
import androidx.core.app.NavUtils;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;
import event.MessageEvent;

public class BaseViewModel extends AndroidViewModel {
    public final MutableLiveData<Throwable> error = new MutableLiveData<>();
    public final MutableLiveData<Boolean> progress = new MutableLiveData<>();

    public BaseViewModel(@NonNull Application application) {
        super(application);
    }


    public void onError(Throwable throwable){
        progress.setValue(false);
        error.setValue(throwable);


    }

    public Map<String,String> json(Object param){
        Gson gson = new Gson();
        String mapJson =  gson.toJson(param);

        Map<String,String> map = gson.fromJson(mapJson,Map.class);

        return map;
    }


}
